<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

// Make sure no one attempts to run this script "directly"... it would be bad
if (!defined('DBC'))
	exit;
	
// Load the viewforum.php language file
if (file_exists(DBC_ROOT.'language/'.$DBC_user['language'].'/forum.php'))
       require DBC_ROOT.'language/'.$DBC_user['language'].'/forum.php';
else
       require DBC_ROOT.'language/English/forum.php';
	   
	$show = isset($show) ? $show : NULL;

    if ($show < '1' || $show > '50' || $show == '') $show = '5'; // Don't mess up with the numbers :P
    
	if ($DBC_user['g_id'] == DBC_ADMIN)
    {
		$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.last_poster_id, t.num_replies, t.num_views, t.moved_to, t.forum_id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE t.moved_to IS NULL ORDER BY t.last_post DESC LIMIT '.$show) or error('Unable to get the admin\'s topic list', __FILE__, __LINE__, $db->error());
    }   
	elseif ($DBC_user['is_guest'])
	{
		$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.last_poster_id, t.num_replies, t.num_views, t.moved_to, t.forum_id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY t.last_post DESC LIMIT '.$show) or error('Unable to get the guest\'s topic list', __FILE__, __LINE__, $db->error());
	}
    else
    {
		$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.last_poster_id, t.num_replies, t.num_views, t.moved_to, t.forum_id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$DBC_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY t.last_post DESC LIMIT '.$show) or error('Unable to get the member\'s topic list', __FILE__, __LINE__, $db->error());
    }
	?>
		<?php
		while ($cur_lasttopic = $db->fetch_assoc($result)) {
		
			if ($DBC_config['o_censoring'] == '1')
				$cur_lasttopic['subject'] = censor_words($cur_lasttopic['subject']);

			$date = format_time($cur_lasttopic['posted']);
			
			$subject = '<a title="'.$lang_common['by_theme'].': '.DBC_htmlspecialchars($cur_lasttopic['poster']).' '.DBC_htmlspecialchars($cur_lasttopic['message']).'<br/> '.$lang_forum['Replies'].': '.DBC_htmlspecialchars($cur_lasttopic['num_replies']).'<br/> '.$lang_forum['Views'].': '.DBC_htmlspecialchars($cur_lasttopic['num_views']).'" href="topic_'.$cur_lasttopic['id'].'">'.DBC_htmlspecialchars($cur_lasttopic['subject']).'</a>';
			
			if (!$DBC_user['is_guest'])
			{
				$tracked_topics = get_tracked_topics();
			}
			
			if (!$DBC_user['is_guest'] && $cur_lasttopic['last_post'] > $DBC_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_lasttopic['id']]) || $tracked_topics['topics'][$cur_lasttopic['id']] < $cur_lasttopic['last_post']) && (!isset($tracked_topics['forums'][$cur_lasttopic['forum_id']]) || $tracked_topics['forums'][$cur_lasttopic['forum_id']] < $cur_lasttopic['last_post']) && $cur_lasttopic['moved_to'] == null)
			{
				$item_status = ' inew';
				$subject = '<strong>'.$subject.'</strong>';
			}
			else
			{
				$item_status = '';
				$icon_type = 'icon';
			}
			?>

<script type="text/javascript">
$(document).ready(function(){
$('table.cClasss').zebra({
	bgEven: '#f5f5f5',
	bgOdd: '#ffffff',
	fontEven: '#none',	
	fontOdd: 'none',
	bgHover: '#none',
	fontHover: 'none'
});
});
</script>


<table cellspacing="0" class="blocktable_mini cClasss" style="width: 190px;">
<tbody>
<tr>
<td align="left" style="padding: 0px 3px 0px; 3px;"><?php echo $subject."\n\t\t" ?></td>
</tr>
<tr><td>

    <div class="bb_cont">
     <ol class="bb_last_feed">
                              <li>

       <address>
	<div class="last_post_img last_block"><a href="user_<?php echo DBC_htmlspecialchars($cur_lasttopic['last_poster_id']) ?>"><?php echo generate_avatar_markup($cur_lasttopic['last_poster_id']) ?></a>
        <?php echo '<span style="color: #ADADAD;">'.$lang_common['by'].' <a href="user_'.DBC_htmlspecialchars($cur_lasttopic['last_poster_id']).'">'.DBC_htmlspecialchars($cur_lasttopic['last_poster']).'</a></span>'; ?><br/>
	
        <p><span class="lasttopic_reply"><?php echo '<a href="topics_'.$cur_lasttopic['last_post_id'].'#p'.$cur_lasttopic['last_post_id'].'" title="'.$lang_common['Topic_post'].' ">'.format_time($cur_lasttopic['last_post']).'</a>'; ?></span></p></div>

       </address>
      </li>
     </ol>
    </div>
</td></tr>
</tbody>
</table>


		<?php
		} // That's all folks!
		?>
<?php

// End the transaction
$db->end_transaction();

// Display executed queries (if enabled)
if (defined('DBC_SHOW_QUERIES'))
	display_saved_queries();

$tpl_temp = trim(ob_get_contents());
$tpl_main = str_replace('{last_tops}', $tpl_temp, $tpl_main, $tpl_search);
ob_end_clean();